//
//  UIButton＋Extension.swift
//  XJWeiBo
//
//  Created by 徐健 on 16/3/14.
//  Copyright © 2016年 徐健. All rights reserved.
//

import UIKit


extension UIButton{
    class func buttonWithImage(imageName: String, backImageName: String)->UIButton{
        
        let btn = UIButton()
        
        btn.setBackgroundImage(UIImage(named: imageName), forState: .Normal)
        btn.setBackgroundImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        btn.setImage(UIImage(named: backImageName), forState: .Normal)
        btn.setImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        
        btn.sizeToFit()
        
        return btn
    }
    
    
    
    class func buttonWithTitle(title: String ,backImageName: String ,textColor: UIColor,fontSize: CGFloat)->UIButton{
        let regBtn = UIButton()
        regBtn.setTitle(title, forState:.Normal)
        regBtn.setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        regBtn.setTitleColor(textColor, forState: .Normal)
        regBtn.titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        regBtn .sizeToFit()
        return regBtn

    }
}
